<template>
    <div class="app-container">
        <el-form class="formBox formBox1 searchForm" :model="queryParams" ref="queryForm" size="small" :inline="true"
            v-show="showSearch" label-width="68px">
            <el-form-item clearable label="医院" prop="hospital">
                <department ref="department" :isHospital="true" :isdepat="true" deptWidth="180px"
                    @refreshData="refreshData">
                </department>
            </el-form-item>
            <el-form-item label="顾客ID" prop="patientId">
                <el-input v-model="queryParams.patientId" placeholder="顾客ID" clearable style="width: 160px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="顾客编号" prop="visitNum">
                <el-input v-model="queryParams.visitNum" placeholder="顾客编号" clearable style="width: 160px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="姓名" prop="patientName">
                <el-input v-model="queryParams.patientName" placeholder="顾客姓名" clearable style="width: 135px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="手机号" prop="patientPhone">
                <el-input v-model="queryParams.patientPhone" placeholder="顾客手机号" clearable style="width: 135px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="身份证号" prop="idNum">
                <el-input v-model="queryParams.idNum" placeholder="顾客身份证号" clearable style="width: 185px"
                    @focus="getSFZToSearch" @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="状态" prop="status">
                <el-select v-model="queryParams.status" filterable placeholder="诊断状态" clearable style="width: 135px">
                    <el-option v-for="dict in dict.type.sys_diagnosis_status" :key="dict.value" :label="dict.label"
                        :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item label="登记日期">
                <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
                    :picker-options="pickerOptions" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                    @change="handleQuery"></el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
            <el-row>
                <div class="btn-photo-query">
                    <el-form-item label="拍照设备">
                        <el-radio-group v-model="queryParams.photoDevice" @change="radioChange">
                            <el-radio v-for="dict in dict.type.photo_upload_type" :key="dict.value"
                                :label="dict.value">{{
            dict.label
        }}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="拍照状态">
                        <el-radio-group v-model="queryParams.photoStatus" :disabled="!queryParams.photoDevice"
                            @change="radioPhotoStatusChange">
                            <el-radio v-for="dict in dict.type.photo_upload_status" :key="dict.value"
                                :label="dict.value">{{
            dict.label
        }}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </div>
            </el-row>
        </el-form>
        <div class="formBox searchForm" ref="statisticalTable" style="margin-bottom:0px!important;">
            <el-row :gutter="10" class="mb8">
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getPatientList"></right-toolbar>
            </el-row>
            <el-table border v-loading="loading" style="width: 100%" :data="patientList" ref="table"
                :height="statisticalTableH" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="50" align="center" />
                <el-table-column label="序号" align="center" type="index" width="50">
                    <template slot-scope="scope">
                        <span>{{ getIndex(scope.$index) }}</span>
                    </template>
                </el-table-column>
                <el-table-column sortable label="顾客ID" align="center" prop="patientId" :show-overflow-tooltip="true"
                    width="80" />
                <el-table-column sortable label="顾客编号" align="center" prop="visitNum" width="140">
                    <template slot-scope="scope">
                        <el-tooltip placement="right" effect="light">
                            <div slot="content" v-html="renderTooltip(scope.row)" style="max-width: 700px" />
                            <span style="text-decoration: underline;color: #10a1df; ">
                                {{ scope.row.visitNum }}
                            </span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column sortable label="顾客姓名" align="center" prop="patientName" :show-overflow-tooltip="true"
                    width="90" />
                <el-table-column sortable label="性别" align="center" prop="sex" width="60">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
                    </template>
                </el-table-column>
                <el-table-column sortable label="年龄" align="center" prop="age" width="60">
                    <!-- <template slot-scope="scope">
              <span>{{
                parseInt(
                  (new Date() - new Date(parseTime(scope.row.birthDate))) /
                  (1000 * 60 * 60 * 24 * 365)
                )
              }}</span>
            </template> -->
                </el-table-column>


                <el-table-column sortable label="状态" align="center" prop="status" :show-overflow-tooltip="true"
                    width="100">
                    <!--                    <template slot-scope="scope">-->
                    <!--                        <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />-->
                    <!--                    </template>-->
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.status == '0'" type="danger" size="mini">
                            <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
                        </el-tag>
                        <el-tag v-else-if="scope.row.status == '1'" type="warning" size="mini">
                            <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
                        </el-tag>
                        <el-tag v-else-if="scope.row.status == '3'" type="success" size="mini">
                            <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
                        </el-tag>
                        <el-tag v-else-if="scope.row.status == '4'" size="mini">
                            <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column sortable label="照片编号" align="center" prop="photoNum" width="90" />

                <!-- <el-table-column sortable label="通用问卷" align="center" prop="questionnaireStatus" width="100px">
                    <template slot-scope="scope">
                        <el-tag :type="scope.row.questionnaireStatus == '1' ? 'danger' : 'primary'
                            ">
                            <dict-tag :options="dict.type.sys_general_questionnaire"
                                :value="scope.row.questionnaireStatus" />
                        </el-tag>
                    </template>
                </el-table-column> -->
                <el-table-column sortable label="霏图" align="center" prop="photoCountFeitu">
                    <template slot-scope="scope">
                        <el-tag size="mini" :type="parseInt(scope.row.photoCountFeitu) > 0 ? 'primary' : 'danger'">{{
            scope.row.photoCountFeitu
        }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column sortable label="VISIA" align="center" prop="photoCountVisa">
                    <template slot-scope="scope">
                        <el-tag size="mini" :type="parseInt(scope.row.photoCountVisa) > 0 ? 'primary' : 'danger'">{{
            scope.row.photoCountVisa
        }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column sortable label="照相机" align="center" prop="photoCountCamara" width="90px">
                    <template slot-scope="scope">
                        <el-tag size="mini" :type="parseInt(scope.row.photoCountCamara) > 0 ? 'primary' : 'danger'">{{
            scope.row.photoCountCamara
        }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column sortable label="照片总数" align="center" prop="photoCount" width="100px">
                    <template slot-scope="scope">
                        <el-tag size="mini" :type="parseInt(scope.row.photoCount) > 0 ? 'primary' : 'danger'">{{
            scope.row.photoCount
        }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column sortable label="就诊门诊" align="center" prop="deptName" :show-overflow-tooltip="true"
                    width="160" />
                <el-table-column sortable label="顾客性质" align="center" prop="properties" width="100">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.sys_patient_properties" :value="scope.row.properties" />
                    </template>
                </el-table-column>
                <el-table-column sortable label="顾客分类" align="center" prop="customerSort" width="100">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.sys_patient_sort" :value="scope.row.customerSort" />
                    </template>
                </el-table-column>
                <el-table-column sortable label="登记人" align="center" prop="createBy" width="100"
                    :show-overflow-tooltip="true" />

                <el-table-column sortable label="登记日期" align="center" prop="createTime" width="180">
                    <template slot-scope="scope">
                        <span>{{ parseTime(scope.row.createTime) }}</span>
                    </template>
                </el-table-column>

                <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width"
                    width="150">
                    <template slot-scope="scope">

                        <el-button size="mini" type="text" icon="el-icon-plus"
                            @click="goPhotoNum(scope.row)">照片编号</el-button>
                        <el-button size="mini" type="text" icon="el-icon-camera"
                            @click="goPhotoList(scope.row)">拍照</el-button>

                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getPatientList" />
        </div>

        <!-- 添加或修改顾客信息对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="650px" append-to-body :close-on-click-modal="false"
            v-dialogDrag>
            <el-form ref="baseInfoForm" :model="baseInfo" :inline="true" :rules="baseInfoFormRules" label-width="80px"
                label-position="left">
                <div class="dialogTitle">
                    <img class="image" :src="require('@/assets/images/dialogTitle.png')" alt="" />
                    <span class="name">基本信息</span>
                </div>
                <el-form-item label="身份证号" prop="idNum">
                    <el-input :disabled="baseInfoInput" v-model="baseInfo.idNum" @blur="changeBirthDate(baseInfo.idNum)"
                        ref="saveTagInput" placeholder="请输入身份证号" style="width: 202px" @focus="getSFZ">
                        <i slot="suffix" class="el-input__icon el-icon-search"></i>
                    </el-input>
                </el-form-item>
                <el-form-item label="卡号" prop="cardNumber">
                    <el-input v-model="baseInfo.cardNumber" placeholder="就诊卡号"></el-input>
                </el-form-item>
                <el-form-item label="姓名" prop="patientName">
                    <el-input v-model="baseInfo.patientName" placeholder="请输入姓名" style="width: 202px" />
                </el-form-item>
                <el-form-item label="性别" prop="sex">
                    <el-select v-model="baseInfo.sex" placeholder="性别" clearable style="width: 202px">
                        <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="出生年月" prop="birthDate">
                    <el-date-picker v-model="baseInfo.birthDate" type="month" placeholder="选择出生年月" style="width: 202px">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="手机号" prop="patientPhone">
                    <el-input v-model="baseInfo.patientPhone" placeholder="请输入手机号" />
                </el-form-item>
                <el-form-item label="患者地址" :prop="isSFZ ? 'area' : ''">
                    <el-cascader v-model="baseInfo.area" placeholder="省,市,区" class="picker-form" :options="areaList"
                        :props="{ children: 'childrenList', value: 'id', label: 'name' }" :clearable="true"
                        style="width: 496px">
                    </el-cascader>
                </el-form-item>
                <el-form-item label="详细地址" prop="address">
                    <el-input v-model="baseInfo.address" placeholder="小区/乡村名称" style="width: 496px"></el-input>
                </el-form-item>

                <el-form-item label="微信号" prop="wxNum">
                    <el-input v-model="baseInfo.wxNum" placeholder="微信小程序登录后自动获取"></el-input>
                </el-form-item>
                <el-form-item label="职业" prop="job">
                    <el-input v-model="baseInfo.job" placeholder="请输入职业"></el-input>
                </el-form-item>
                <div class="dialogTitle">
                    <img class="image" :src="require('@/assets/images/dialogTitle.png')" alt="" />
                    <span class="name">医疗信息</span>
                </div>
                <el-form-item label="顾客性质" prop="properties">
                    <el-select v-model="baseInfo.properties" placeholder="请选择顾客性质" clearable style="width: 202px">
                        <el-option v-for="dict in dict.type.sys_patient_properties" :key="dict.value"
                            :label="dict.label" :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="皮肤色度" prop="tone">
                    <el-select v-model="baseInfo.tone" placeholder="请选择皮肤色度" clearable style="width: 202px">
                        <el-option v-for="dict in dict.type.sys_skin_tone" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="顾客分类" prop="customerSort">
                    <el-select v-model="baseInfo.customerSort" placeholder="请选择顾客分类" clearable style="width: 202px">
                        <el-option v-for="dict in dict.type.sys_patient_sort" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item class="formItemRed" label="就诊门诊" prop="deptId">
                    <!--          <treeselect v-model="baseInfo.deptId" :options="deptOptions" :show-count="true" placeholder="请选择就诊门诊" style="width: 202px" />-->
                    <treeselect v-model="baseInfo.deptId" :options="deptOptions" :normalizer="normalizer"
                        placeholder="请选择就诊门诊" style="width: 202px" :disable-branch-nodes="true" />
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                    <el-input v-model="baseInfo.remark" type="textarea" placeholder="请输入内容"
                        style="width: 496px"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="submitForm">提 交</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 诊前问卷 -->
        <el-dialog :title="questionnaireTitle" :visible.sync="questionnaireDialog" width="1000px"
            :close-on-click-modal="false" v-dialogDrag>
            <formpreview v-if="formpreviewContList != null" :formPreviewList="formpreviewContList" ref="formPreview"
                :questionFormInfo="questionFormInfo" />
            <div slot="footer" class="dialog-footer">
                <el-button v-if="dialogNewAddBtnStatus === true" @click="submitAnswer">提 交</el-button>
                <el-button v-else @click="updateFormAnswer">修 改</el-button>
                <el-button @click="questionnaireDialog = false">取 消</el-button>
            </div>
        </el-dialog>
        <!-- 删除原因-->
        <el-dialog :title="deleteTitle" :visible.sync="deleteDialog" width="30%" :close-on-click-modal="false"
            v-dialogDrag>
            <el-form label-position="top" :model="deleteForm" :rules="deleteRules" ref="deleteForm" label-width="100px">
                <el-form-item :label="deleteLable" prop="delCause">
                    <el-radio-group v-model="deleteForm.delCause">
                        <el-radio v-for="dict in dict.type.sys_patient_reason" :key="dict.value" :label="dict.label"
                            :value="dict.value"></el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="deleteReason">确 定</el-button>
                <el-button @click="deleteDialog = false">取 消</el-button>
            </div>
        </el-dialog>
        <!--    新增确认-->
        <el-dialog title="新增提示" :visible.sync="confirmDialog" width="30%" :close-on-click-modal="false"
            :show-close="false" v-dialogDrag>
            <!--      <div>-->
            <!--        该顾客此时的状态为:-->
            <!--        <dict-tag style="display: inline; font-weight: bold; font-size: 18px" :options="dict.type.sys_diagnosis_status"-->
            <!--          :value="baseInfo.status" />-->
            <!--      </div>-->
            <!--      <span>确定新增登记吗?新登记后开始新一次就诊,并赋予新的顾客编号。</span>-->
            <div>该顾客登记于<span class="confirmBox"> {{ parseTime(baseInfo.createTime) }}</span></div>
            <div>就诊门诊:<span class="confirmBox">{{ baseInfo.deptName }}</span></div>
            <div>
                当前状态为:
                <dict-tag class="confirmBox" :options="dict.type.sys_diagnosis_status" :value="baseInfo.status" />
            </div>
            <div v-if="deptOptionsStatus" style="font-size: 16px;margin-top: 10px">
                <div v-if="baseInfo.status != '3'">本次登记是想登记一个新门诊?</div>
                <div v-else>本次登记是想登记一个新门诊?还是老门诊复诊?</div>
            </div>
            <div v-else style="font-size: 16px;margin-top: 10px">
                <div v-if="baseInfo.status == '4'">本次登记是想登记一个新门诊?</div>
                <div v-if="baseInfo.status == '3'">是否为复诊?</div>
                <div v-if="baseInfo.status == '0' || baseInfo.status == '1'">您不需要重新登记。</div>
            </div>


            <div slot="footer" class="dialog-footer" v-if="deptOptionsStatus">
                <el-button @click="confirmDialog = false">登记新门诊</el-button>
                <el-button @click="closeDialog" v-if="baseInfo.status != '3'">否</el-button>
                <el-button @click="uploadReview" v-else>复诊</el-button>
            </div>
            <div slot="footer" class="dialog-footer" v-else>
                <el-button @click="closeDialog" v-if="baseInfo.status == '0' || baseInfo.status == '1'">我已知晓</el-button>
                <el-button @click="uploadReview" v-if="baseInfo.status == '3'">复诊</el-button>
                <el-button @click="confirmDialog = false" v-if="baseInfo.status == '4'">登记新门诊</el-button>
                <el-button @click="closeDialog" v-if="baseInfo.status == '3' || baseInfo.status == '4'">否</el-button>
            </div>
        </el-dialog>
        <!-- 详情 -->
        <el-dialog :title="detailTitle" :visible.sync="detailDialogVisible" width="85%" center
            :close-on-click-modal="false" v-dialogDrag>
            <CustomerDetails v-if="detailDialogVisible" :basicInfo="basicInfo"></CustomerDetails>
        </el-dialog>
        <!-- 照片编号 -->

        <el-dialog title="新增顾客编号" :visible.sync="photoNumDialogVisible" :close-on-click-modal="false" width="30%"
            v-dialogDrag>
            <el-form :model="photoNumForm" ref="photoNumForm" label-position="top" label-width="100px">
                <el-form-item label="照片编号" prop="photoNum" :rules="[
            { required: true, message: '照片编号不能为空', trigger: 'blur' },
        ]">
                    <el-input v-model="photoNumForm.photoNum"></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="getPhotoNum">确 定</el-button>
                <el-button @click="photoNumDialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>

    </div>
</template>

<script>
import {
    addVisit,
    deleteVisit,
    getDetailVisit,
    listVisitTip,
    getVisitStatus,
    updateVisit,
    getQuestionnaireCommon, listVisitTipNew, getPhotoNum,
} from "@/api/patientRegistration/registrationList";
import { addressJson } from "@/api/patients/personal";
import department from "@/views/components/department/index.vue";
import { deptTreeSelect } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {
    listFormCont,
    addFormAnswer,
    listAnswer,
    updateAnswer,
    currencyFormId,
    detailFormAndAnswer,
} from "@/api/system/form";
import Formpreview from "@/views/system/form/Formpreview";
import CustomerDetails from "@/views/components/customerDetail/customerDetail";
import { startReadCard } from "@/utils/getIdCard"
import { uploadReview } from "@/api/patientReview/review";
import { listDept } from "@/api/system/dept";
import { getFilterPhoto } from "@/api/photoWorkstation/photoList";

//自定义校验规则
var checkIdCard = (rule, value, cb) => {
    const regIdCard =
        /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    if (regIdCard.test(value)) {
        return cb();
    }
    cb(new Error("您输入的身份证号码不是有效格式"));
};
var checkPatientPhone = (rule, value, cb) => {
    const regPatientPhone = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
    if (regPatientPhone.test(value)) {
        return cb();
    }
    cb(new Error("您输入的手机号码不是有效格式"));
};

export default {
    name: "Registration",
    dicts: [
        "sys_diagnosis_status",
        "sys_user_sex",
        "sys_patient_properties",
        "sys_skin_tone",
        "sys_patient_sort",
        "sys_outpatient_clinic",
        "sys_general_questionnaire",
        "sys_patient_reason",
        "photo_upload_type",
        "photo_upload_status",
    ],
    components: { Treeselect, Formpreview, CustomerDetails, department },
    data() {

        return {
            statisticalTableH: undefined,
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now() - 8.64e6;  //如果没有后面的-8.64e6就是不可以选择今天的
                },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        const end = date;
                        const start = date;
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '前天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 2);
                        const end = date;
                        const start = date;
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近六个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近1年',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            },
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            patientNames: [],
            patientItem: '',
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 登记顾客列表
            patientList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                deptId: undefined, // deptId: 0,
                hospitalId: undefined,
                patientId: undefined,
                visitNum: undefined,
                patientName: undefined,
                patientPhone: undefined,
                idNum: undefined,
                status: undefined,
                photoDevice: undefined,
                photoStatus: undefined,
            },
            // 新增顾客信息

            // 弹出层标题
            title: "",
            // 科室树选项
            deptOptions: undefined,
            // 是否显示弹出层
            open: false,
            // 科室名称
            deptName: undefined,
            // 日期范围
            dateRange: [],
            // 顾客信息
            baseInfo: {
                address: undefined,
                area: undefined,
                birthDate: undefined,
                cardNumber: undefined,
                cityId: undefined,
                countyId: undefined,
                customerSort: undefined,
                deptId: undefined, // deptId: 0,
                hospitalId: undefined,
                diagnosis: undefined,
                doctorId: undefined,
                doctorTime: undefined, //"2023-03-09T11:42:21.539Z"
                idNum: undefined,
                job: undefined,
                patientId: undefined,
                patientName: undefined,
                patientPhone: undefined,
                properties: "0",
                provinceId: undefined,
                questionnaireStatus: undefined,
                referee: undefined,
                refereeTime: undefined, //2023-03-09T11:42:21.539Z
                remark: undefined,
                sex: undefined,
                status: undefined,
                tone: undefined,
                visitId: undefined,
                visitNum: undefined,
                wxNum: undefined,
            },
            // 省市区
            areaList: [],
            // 表单校验
            baseInfoFormRules: {
                idNum: [
                    {
                        required: true,
                        message: "身份证号不能为空",
                        trigger: "blur",
                    },
                    { validator: checkIdCard, trigger: "blur" },
                ],
                patientName: [
                    {
                        required: true,
                        message: "姓名不能为空",
                        trigger: "blur",
                    },
                ],
                sex: [
                    {
                        required: true,
                        message: "性别不能为空",
                        trigger: "blur",
                    },
                ],
                birthDate: [
                    {
                        required: true,
                        message: "出生年月不能为空",
                        trigger: "blur",
                    },
                ],
                patientPhone: [
                    {
                        required: true,
                        message: "手机号不能为空",
                        trigger: "blur",
                    },
                    { validator: checkPatientPhone, trigger: "blur" },
                ],
                properties: [
                    {
                        required: true,
                        message: "顾客性质不能为空",
                        trigger: "blur",
                    },
                ],
                deptId: [
                    {
                        required: true,
                        message: "就诊科室不能为空",
                        trigger: "blur",
                    },
                ],
            },
            // 禁止修改
            baseInfoInput: false,

            // 诊前问卷弹出层标题
            questionnaireTitle: "",
            // 诊前问卷弹出层是否显示
            questionnaireDialog: false,
            // 诊前问卷表单
            questionnaireForm: {
                name: "",
                region: "",
                type: "",
            },
            questionnaireRules: {
                name: [
                    {
                        required: true,
                        message: "未勾选",
                        trigger: "blur",
                    },
                ],
            },
            deleteForm: {
                delCause: "",
            },
            deleteRules: {
                delCause: [
                    {
                        required: true,
                        message: "未勾选",
                        trigger: "blur",
                    },
                ],
            },
            formpreviewContList: null,
            formInfo: {},
            questionFormInfo: {
                name: "",
                remark: "",
            },
            // 删除原因弹出框
            deleteDialog: false,
            deleteTitle: "",
            deleteLable: "",
            // 确认新增弹出框
            confirmDialog: false,
            confirmTitle: "",
            dialogNewAddBtnStatus: "", //诊前问卷弹窗新增或者修改状态
            myAnswer: null, //存放表单答案
            detailTitle: "",
            detailDialogVisible: false,
            photoNumDialogVisible: false,
            photoNumForm: {
                photoNum: ''
            },
            basicInfo: {},
            searchDeptId: '',
            deptOptionsStatus: true,
            visitIdStatus: false,
            isSFZ: true,
            deptOptionsArr: [],

        };
    },
    watch: {
        // 根据名称筛选科室树
        deptName(val) {
            this.$refs.tree.filter(val);
        },
        showSearch() {
            console.log("执行----****")
            this.$nextTick(() => {
                this.changeHeight()
            }, 1000)

        }
    },
    async created() {
        this.dateRange = this.defaultTime
    },
    mounted() {
        this.changeHeight()
    },
    updated() {
        this.$nextTick(() => {
            this.$refs.table.doLayout()
        })
    },
    computed: {
        defaultTime: function () {
            let date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day = date.getDate();
            month = month > 9 ? month : "0" + month;
            day = day < 10 ? "0" + day : day;
            let today = year + "-" + month + "-" + day;
            return [today, today];
        },
    },
    methods: {
        changeHeight() {
            if (this.$refs.statisticalTable) {
                const statisticalTableObj = this.$refs.statisticalTable.getBoundingClientRect();
                let h = statisticalTableObj.top + 100
                this.statisticalTableH = 'calc(100vh - ' + h + 'px)'
            } else {
                this.statisticalTableH = '500px'
            }
        },
        refreshData(data) {
            this.queryParams.pageNum = 1;
            this.queryParams.hospitalId = data.hospitalId;
            this.queryParams.deptId = data.deptId;
            // 获取拍照设备
            this.queryParams.photoDevice = localStorage.getItem('photoDevice') || '0'
            this.queryParams.photoStatus = localStorage.getItem('photoStatus') || ''

            this.getPatientList();
            this.getAddressData();
            this.getDeptTree();
        },
        renderTooltip(row) {
            return `<div style="margin-bottom:5px;font-size:20px;color:#1890ff;"><span style="font-weight:bold;"> 顾客状态：</span>${this.matchDict("sys_diagnosis_status", row.status)}</div>
        <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">登记日期：</span>${this.parseTime(row.createTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">登记人：</span>${this.formatValue(row.createBy)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">就诊科室：</span>${this.formatValue(row.deptName)}</span> </div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">顾客性质：</span>${this.matchDict("sys_patient_properties", row.properties)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">顾客分类：</span>${this.matchDict("sys_patient_sort", row.customerSort)}</span></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">地址：</span>${this.formatValue(row.address)}</div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">电话：</span>${this.formatValue(row.patientPhone)}</div>
        <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">通用问卷：</span>${this.matchDict("sys_general_questionnaire", row.questionnaireStatus)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">专病问卷：</span>${this.formatValue(row.diseaseQuestionnaireStatus)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">照片：</span>${this.formatValue(row.photoCount)}</span></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">咨询日期：</span>${this.formatValue(row.consultationTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">咨询医生：</span>${this.formatValue(row.consultationer)}</span></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">咨询诊断：</span>${this.formatValue(row.consultationDiagnosis)}</div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">咨询方案：</span>${this.formatValue(row.consultationPlan)}</div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">方案总额：</span>${this.formatValue(row.consultationTotalExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗费用：</span>${this.formatValue(row.consultationTreatmentExpenses)}</span></div>
        <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">诊断日期：</span>${this.formatValue(row.doctorTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">诊断医生：</span>${this.formatValue(row.doctor)}</span></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">医生诊断：</span>${this.formatValue(row.doctorDiagnosis)}</div>
        <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">医生方案：</span>${this.formatValue(row.doctorPlan)}</div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">方案总额：</span>${this.formatValue(row.doctorTotalExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗费用：</span>${this.formatValue(row.doctorTreatmentExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">复诊次数：</span>${this.formatValue(row.reviewNum)}</span></div>
        <div style="width: 100%;height: 1px;background-color: red;margin-bottom:5px;"></div>
        <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">知情同意书：</span>${this.formatValue(row.informedConsent)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">确费状态：</span>${this.formatValue(row.confirmExpense == '1' ? '已确费' : '未确费')}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗次数：</span>${this.formatValue(row.treatmentTimes)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">温馨提示：</span>${this.formatValue(row.tipsTimes)}</span></div>`
        },
        /** id转化成对应的文字 */
        matchDict: function (key, id) {
            let _this = this;
            const result = _this.dict.type[key];
            let textValue = "";
            result.forEach((item) => {
                if (item.raw.dictValue == id) {
                    textValue = item.raw.dictLabel;
                }
            });
            return textValue;
        },
        formatValue(value) {
            if (value == null) {
                return ''
            } else {
                return value
            }
        },
        radioChange(value) {
            localStorage.setItem('photoDevice', value);
            this.handleQuery()
        },
        radioPhotoStatusChange(value) {
            localStorage.setItem('photoStatus', value);
            this.handleQuery()
        },
        async getSFZ() {
            const res = await startReadCard()
            if (res.result == 3) {
                this.isSFZ = true
                this.$message.warning('请把身份证放到读卡器上')
                // this.$refs.saveTagInput.blur();
            } else if (res.result == 2) {
                // this.$message.warning('设备不存在')
                this.isSFZ = true
            } else {
                this.isSFZ = false
                this.baseInfo.idNum = res.gmsfhm
                this.baseInfo.patientName = res.xm
                this.baseInfo.sex = res.xbmc == '男' ? "0" : res.xbmc == '女' ? "1" : ''
                this.baseInfo.address = res.dzmc
                this.changeBirthDate(res.gmsfhm)
            }
        },
        async getSFZToSearch() {
            const res = await startReadCard()
            if (res.result == 3) {
                this.$message.warning('请把身份证放到读卡器上')
                // this.$refs.saveTagInput.blur();
            } else if (res.result == 2) {
                // this.$message.warning('设备不存在')
            } else {
                this.queryParams.idNum = res.gmsfhm
            }

        },
        submitAnswer() {
            this.$nextTick(() => {
                this.$refs.formPreview.$refs.listForm.validate((valid) => {
                    console.log(this.$refs.formPreview.$refs.listForm);
                    if (valid) {
                        let answerArr = [];
                        const Vmodel = this.$refs.formPreview.$refs.listForm.model;
                        Object.keys(Vmodel).forEach((item) => {
                            answerArr.push({ answer: Vmodel[item], questionId: null });
                        });
                        this.formpreviewContList.forEach((item, index) => {
                            this.$set(answerArr[index], "questionId", item.questionId);
                        });
                        let answerStr = JSON.stringify(answerArr);
                        let mData = {
                            visitId: this.formInfo.visitId,
                            patientId: this.formInfo.patientId,
                            formId: this.formInfo.formId,
                            answer: answerStr,
                            formType: 0, //通用表单
                        };
                        addFormAnswer(1, mData).then((response) => {
                            this.$message.success("提交成功");
                            this.questionnaireDialog = false;
                            this.getPatientList();
                        });
                    }
                });
            });
        },

        // 获取地区
        getAddressData() {
            addressJson().then((res) => {
                this.areaList = res.data;
            });
        },
        /** 查询科室下拉树结构 */
        getDeptTree() {
            // deptTreeSelect().then((response) => {
            //   this.deptOptions = response.data[0].children;
            //   // console.log('getDeptTree--',this.deptOptions)
            //   if(this.deptOptions.length==1){
            //     this.baseInfo.deptId = this.deptOptions[0].id
            //   }
            // });
            listDept().then(response => {
                this.deptOptionsArr = response.data
                this.deptOptions = this.handleTree(response.data, "deptId")[0].children;
                if (this.deptOptions.length == 1) {
                    this.baseInfo.deptId = this.deptOptions[0].deptId
                    if (this.deptOptions[0].parentId != 0) {
                        this.baseInfo.hospitalId = this.deptOptions[0].parentId
                    }
                }
                // console.log('this.deptOptions ',this.deptOptions )
            });
        },
        /** 转换部门数据结构 */
        normalizer(node) {
            if (node.children && !node.children.length) {
                delete node.children;
            }
            return {
                id: node.deptId,
                label: node.deptName,
                children: node.children
            };
        },
        changeBirthDate(idCard) {
            var birthday = "";
            if (idCard != null && idCard != "") {
                if (idCard.length == 15) {
                    birthday = "19" + idCard.substr(6, 6);
                } else if (idCard.length == 18) {
                    birthday = idCard.substr(6, 8);
                }

                birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
            }
            this.baseInfo.birthDate = birthday;
            // console.log(birthday);
            // return birthday;
            if (!birthday) {
                return
            }
            getVisitStatus(idCard).then((response) => {
                // console.log("getVisitStatus", response);
                if (response.data.idNum) {
                    this.confirmDialog = true;
                    this.baseInfo = response.data;
                    this.baseInfo.area = [
                        Number(response.data.provinceId),
                        Number(response.data.cityId),
                        Number(response.data.countyId),
                    ];
                    this.baseInfo.questionnaireStatus = '1'
                    this.baseInfoInput = true;
                    //比对deptId门诊(新增逻辑部分)
                    if (Number(response.data.status) < 4) {
                        this.searchDeptId = response.data.deptId
                        // if (this.deptOptions.length > 1) {
                        //   this.deptOptions = this.deptOptions.filter((item) => {
                        //     return item.id != this.searchDeptId
                        //   })
                        //   this.deptOptionsStatus = true
                        //   this.baseInfo.deptId = this.deptOptions[0].id
                        // } else {
                        //   this.deptOptionsStatus = false
                        // }
                        if (this.deptOptions.length > 1) {
                            this.deptOptions = this.deptOptions.filter((item) => {
                                return item.deptId != this.searchDeptId
                            })
                            this.deptOptionsStatus = true
                            this.baseInfo.deptId = this.deptOptions[0].deptId
                        } else {
                            this.deptOptionsStatus = false
                        }

                    } else {

                    }


                } else {
                    // this.confirmDialog=true
                }
            });
        },
        // 真实序号计算（计算分页影响）
        getIndex(index) {
            return (
                (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
            );
        },

        // 获取顾客登记列表
        getPatientList() {
            this.loading = true;
            // listVisitTipNew(this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
            //       this.patientList = response.rows;
            //       this.total = response.total;
            //       this.loading = false;
            //   });
            if (this.queryParams.visitNum || this.queryParams.patientId) {
                this.dateRange = []
                this.queryParams.photoDevice = ''
                this.queryParams.photoStatus = ''
            }
            getFilterPhoto(this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
                if (response.code == 200) {
                    this.patientList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                } else {
                    this.loading = false;

                }


            });
        },

        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.isSFZ = true
            this.baseInfo = {
                address: undefined,
                area: undefined,
                birthDate: undefined,
                cardNumber: undefined,
                cityId: undefined,
                countyId: undefined,
                customerSort: undefined,
                deptId: undefined, // deptId: 0,
                hospitalId: undefined,
                diagnosis: undefined,
                doctorId: undefined,
                doctorTime: undefined, //"2023-03-09T11:42:21.539Z"
                idNum: undefined,
                job: undefined,
                patientId: undefined,
                patientName: undefined,
                patientPhone: undefined,
                properties: "0",
                provinceId: undefined,
                questionnaireStatus: undefined,
                referee: undefined,
                refereeTime: undefined, //2023-03-09T11:42:21.539Z
                remark: undefined,
                sex: undefined,
                status: undefined,
                tone: undefined,
                visitId: undefined,
                visitNum: undefined,
                wxNum: undefined,
            };
            this.resetForm("baseInfoForm");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getPatientList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.queryParams.photoDevice = ''
            this.queryParams.photoStatus = ''
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.baseInfoInput = false;
            this.open = true;
            this.title = "新增顾客";
            this.visitIdStatus = false;
            this.getDeptTree();

        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.visitId);
            this.patientNames = selection.map((item) => item.patientName);
            this.patientItem = selection.map((item) => item);

            // console.log('this.patientItem',this.patientItem)
            this.single = selection.length != 1;
            this.multiple = selection.length != 1;
            // this.multiple = !selection.length;
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.getDeptTree();
            this.visitIdStatus = true;
            // console.log('handleUpdate',this.patientItem)
            if (Number(this.patientItem[0].status) == 4) {
                this.$confirm(`该顾客治疗结束,无法修改基本信息!`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                })
                    .then((content) => {
                        return
                    })
                    .catch((error) => {
                        return
                    })
            } else {
                this.reset();
                this.baseInfoInput = true;
                const visitId = row.visitId || this.ids;
                getDetailVisit(visitId).then((response) => {
                    this.baseInfo = response.data;
                    this.baseInfo.area = [
                        Number(response.data.provinceId),
                        Number(response.data.cityId),
                        Number(response.data.countyId),
                    ];
                    this.open = true;
                    this.title = "修改顾客";
                    // console.log('getDetailVisit', this.baseInfo)
                });
            }


        },
        getSplit(str) {
            return str.split(',')
        },
        /** 提交按钮 */
        submitForm: function () {
            this.$refs["baseInfoForm"].validate((valid) => {
                if (!!this.baseInfo.area) {
                    this.baseInfo.provinceId = String(this.baseInfo.area[0]);
                    this.baseInfo.cityId = String(this.baseInfo.area[1]);
                    this.baseInfo.countyId = String(this.baseInfo.area[2]);
                }
                let deptOptionsArr = this.deptOptionsArr
                // deptId: undefined, // deptId: 0,
                // hospitalId:undefined,

                // console.log("this.baseInfo.visitId", this.baseInfo.visitId);
                if (valid) {
                    let that = this


                    deptOptionsArr.forEach(function (ele) {
                        console.log(ele.deptId)
                        if (ele.deptId == that.baseInfo.deptId) {
                            console.log(ele)
                            console.log("___专病————")
                            if (that.getSplit(ele.ancestors).length != 2 && that.getSplit(ele.ancestors).length != 1) {
                                that.baseInfo.hospitalId = ele.parentId
                            } else {
                                that.baseInfo.hospitalId = ele.deptId
                            }
                        }
                    })
                    if (this.visitIdStatus) {
                        console.log('this.baseInfo--updateVisit', this.baseInfo)
                        updateVisit(this.baseInfo).then((response) => {
                            console.log("updateVisit", this.baseInfo);
                            this.$modal.msgSuccess("修改成功");
                            this.open = false;
                            this.getPatientList();
                        });
                    } else {
                        this.baseInfo.status = '0'
                        this.baseInfo.visitNum = null
                        delete this.baseInfo.visitId
                        console.log('this.baseInfo--addVisit', this.baseInfo)
                        addVisit(this.baseInfo).then((response) => {
                            console.log("addVisit", this.baseInfo);
                            this.$modal.msgSuccess("新增成功");
                            this.open = false;
                            this.getPatientList();
                        });
                    }
                }
            });
        },
        /** 诊前问卷按钮操作 */
        async openQuestionnaire(row) {
            this.formInfo = row;
            currencyFormId().then((res) => {
                if (res.code == 200) {
                    this.formInfo.formId = res.data;
                    if (res.data) {
                        this.getFormContList();
                    }
                    this.dialogNewAddBtnStatus = true;
                    this.questionnaireTitle = "新增顾客通用诊前问卷";
                }

            });
        },
        /** 修改诊前问卷按钮操作 */
        updateQuestionnaire(row) {
            this.dialogNewAddBtnStatus = false;
            getQuestionnaireCommon(row.visitId).then((response) => {
                const visitLogId = response.data[0].visitLogId;
                console.log("点击修改按钮获取的答案和表单列表", this.myAnswer);
                detailFormAndAnswer(visitLogId).then((response) => {
                    this.formInfo = response.data;
                    this.myAnswer = JSON.parse(response.data.answer);
                    this.getFormContList();
                });
            });
            this.questionnaireTitle = "修改顾客通用诊前问卷";

        },
        /** 修改诊前问卷按钮操作 */
        async updateFormAnswer() {
            this.$nextTick(() => {
                this.$refs.formPreview.$refs.listForm.validate((valid) => {
                    if (valid) {
                        let answerArr = [];
                        const Vmodel = this.$refs.formPreview.$refs.listForm.model;
                        Object.keys(Vmodel).forEach((item) => {
                            answerArr.push({ answer: Vmodel[item], questionId: null });
                        });
                        this.formpreviewContList.forEach((item, index) => {
                            this.$set(answerArr[index], "questionId", item.questionId);
                        });
                        let answerStr = JSON.stringify(answerArr);
                        let mData = {
                            visitLogId: this.formInfo.visitLogId,
                            answer: answerStr,
                        };
                        updateAnswer(1, mData).then((response) => {
                            if (response.code == 200) {
                                this.$message.success("修改成功");
                                this.questionnaireDialog = false;
                            }

                        });
                    }
                });
            });
        },

        /** 查询表单内容控件列表 */
        getFormContList() {
            listFormCont({
                formId: this.formInfo.formId,
            }).then((response) => {
                this.questionFormInfo.name = response.name;
                this.questionFormInfo.remark = response.remark;
                this.formpreviewContList = response.rows;
                this.formpreviewContList.forEach((item, index) => {
                    if (this.dialogNewAddBtnStatus === false) {
                        this.$set(item, "answer", this.myAnswer[index].answer);
                    } else {
                        if (item.questionType === "2") {
                            this.$set(item, "answer", []);
                        } else {
                            this.$set(item, "answer", null);
                        }
                    }
                });
            });
            this.questionnaireDialog = true;
        },
        // 填写照片编号
        goPhotoNum(row) {
            this.photoNumDialogVisible = true
            this.basicInfo = row;
            console.log('this.basicInfo', this.basicInfo)

        },
        getPhotoNum() {
            this.$refs["photoNumForm"].validate((valid) => {
                if (valid) {
                    console.log('000000', valid)
                    getPhotoNum(this.basicInfo.visitId, this.photoNumForm).then(response => {
                        if (response.code == 200) {
                            this.$modal.msgSuccess(response.msg);
                            this.photoNumDialogVisible = false
                            this.handleQuery()
                        }


                    })

                }


            });
        },
        /** 拍照按钮操作 */
        goPhotoList(row) {
            // const userInfo = {
            //   visitNum: row.visitNum,
            //   patientName: row.patientName,
            //   patientPhone: row.patientPhone,
            //   idNum: row.idNum,
            // };
            // this.$store.dispatch("app/changePhotoUserInfo", userInfo);
            // this.$router.push("/photoWorkstation/photoList");
            this.$router.push({ path: "/photoWorkstation/index", query: { visitNum: row.visitNum } });
        },
        goDetail(row) {
            // this.$router.push("/patientRegistration/patientRegistration-detail/index/" + row.patientId);
            this.detailTitle = "顾客详情";
            this.basicInfo = row;
            this.detailDialogVisible = true;
        },

        /** 删除按钮操作 */
        handleDelete(row) {
            if (Number(this.patientItem[0].status) > 0) {
                this.$confirm(`该顾客不是待咨询状态,无法删除基本信息!`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    dangerouslyUseHTMLString: true,
                })
                    .then((content) => {
                        return
                    })
                    .catch((error) => {
                        return
                    })
            } else {
                const patientNames = row.patientName || this.patientNames;
                this.deleteDialog = true;
                this.deleteTitle = "删除顾客";
                this.deleteLable = '确定删除"' + patientNames + '"的顾客资料吗？请选择删除原因';
            }



        },
        // 删除原因
        deleteReason() {
            // const visitIds = String(this.ids[0]);
            const visitIds = this.ids;
            const delCause = this.deleteForm.delCause;
            this.$refs["deleteForm"].validate((valid) => {
                if (valid) {
                    deleteVisit(visitIds, delCause).then((response) => {
                        this.$modal.msgSuccess("删除成功");
                        this.deleteDialog = false;
                        this.getPatientList();
                    });
                }
            });
        },
        // 关闭弹窗
        closeDialog() {
            this.confirmDialog = false;
            this.open = false;
            this.getPatientList();
        },
        //复诊
        uploadReview() {
            uploadReview(this.baseInfo.visitNum).then(response => {
                if (response.code == 200) {
                    this.confirmDialog = false;
                    this.open = false;
                    this.getPatientList();
                }
            })

        },
    },
};
</script>
<style scoped rel="stylesheet/scss" lang="scss">
::v-deep .el-dialog {
    margin-top: 0 !important;
}

.confirmBox {
    display: inline;
    font-weight: bold;
    font-size: 18px
}

.el-radio-group {
    margin-left: 12px;
}

.btn-photo-query {
    width: 600px;
    height: 38px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    background-color: rgba($color: #1FC, $alpha: 0.8);
    border-radius: 10px;
    padding: 5px 10px;
}
</style>
